<?php
/* 
 * Amnesia is Copyright (c) 2010 Mark Russell
 * 
 * Contact: info@amnesia-app.com	
 * 
 * This file is part of Amnesia.
 * 
 * Amnesia is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * Amnesia is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with Amnesia. If not, see <http://www.gnu.org/licenses/>.
 *
 */

include '../../db/db.php';


$user_id = mysql_real_escape_string ($_POST[user_id]);
$cat_name = mysql_real_escape_string ($_POST[cat_name]);

// Select the example data from DB

switch ($cat_name) {
    case "web":
    	$query = "SELECT `web_id` FROM `web` WHERE `user_id`= " . $user_id . " ORDER BY `web_id` DESC";
    	break;
    case "hosted":
        $query = "SELECT `hosted_id` FROM `hosted` WHERE `user_id`= " . $user_id . " ORDER BY `hosted_id` DESC";
		break;
	case "phone":
        $query = "SELECT `phone_id` FROM `phone` WHERE `user_id`= " . $user_id . " ORDER BY `phone_id` DESC";
		break;
	case "license":
       	$query = "SELECT `license_id` FROM `license` WHERE `user_id`= " . $user_id . " ORDER BY `license_id` DESC";
		break;
	case "cards":
       	$query = "SELECT `cards_id` FROM `cards` WHERE `user_id`= " . $user_id . " ORDER BY `cards_id` DESC";
        break;
    case "banking":
        $query = "SELECT `banking_id` FROM `banking` WHERE `user_id`= " . $user_id . " ORDER BY `banking_id` DESC";
		break;
	case "email":
        $query = "SELECT `email_id` FROM `email` WHERE `user_id`= " . $user_id . " ORDER BY `email_id` DESC";
		break;
	case "computer_user":
        $query = "SELECT `computer_user_id` FROM `computer_user` WHERE `user_id`= " . $user_id . " ORDER BY `computer_user_id` DESC";
		break;
	case "hardware":
        $query = "SELECT `hardware_id` FROM `hardware` WHERE `user_id`= " . $user_id . " ORDER BY `hardware_id` DESC";
        break;
	case "certificates":
        $query = "SELECT `certificates_id` FROM `certificates` WHERE `user_id`= " . $user_id . " ORDER BY `certificates_id` DESC";
		break;
	case "notes":
        $query = "SELECT `notes_id` FROM `notes` WHERE `user_id`= " . $user_id . " ORDER BY `notes_id` DESC";
		break;
}

if(!($result = @ mysql_query ($query, $con)))
   showerror();

$result = mysql_query($query);

$xml = "";

$array = mysql_fetch_row($result);

	$id = $array[0];
	
	$xml .= "<record>";
	$xml .= "<last_id>$id</last_id>";
	$xml .= "</record>";
 


header('Content-Type: application/xml; charset=ISO-8859-1');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>";
echo "<records>";
echo $xml;
echo "</records>";

mysql_close($con);
?>